﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <stdio.h>
#include<string.h>
#include "conio.h"
#include <windows.h>
#include <vector>
#define Row 13//行
#define Column 13//列
int map[13][13] = { 0 };
using std::endl;
using std::cin;
using std::cout;
using std::vector;
class CHero;
class CGoods;
HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);

enum ETYPEBase
{
	ETYPE_HERO = 2,//英雄

	ETYPE_WALL,//墙

	ETYPE_MONSTER,//怪物

	EGOODS_FLY, //飞行

	EGOODS_ATT = 100, //红宝石
	EGOODS_DEF, //黄宝石

	EGOODS_HP, //血瓶

	EGOODS_LOOK,//怪物图鉴

	EGOODS_YELLOWKEY,//黄钥匙
	EGOODS_REDKEY,//红钥匙
	EGOODS_BULEKEY,//蓝钥匙

	ESTAIR_UP = 1,//上楼
	ESTAIR_DOWN = -1,//下楼

	EDOOR_REDDOOR = 300,//红门
	EDOOR_BULEDOOR,//蓝门
	EDOOR_YELLOWDOOR,//黄门
};
enum EMOVE
{
	EMOVE_UP,
	EMOVE_DOWN,
	EMOVE_LEFT,
	EMOVE_RIGHT,
};
void InitObj(ETYPEBase Type);
int n_CBaseSize;//20
int n_CStairsSize;//20
int n_CWallSize;//20
int n_CHeroSize;//100
int n_CMonsterSize;//68
int n_CGoodsHpSize;//24
int n_CGoodsGemSize;//24
int n_CDoorSize;//20
int n_CGoodsKeySize;//24


int n_CCopyTempSize;
class CCopyTemp//副本—存档用
{
private:
	ETYPEBase Type;
	int m_nx;//x坐标
	int m_ny;//y坐标
	char m_cname[20];//姓名
	int m_nMaxFloor;//最大楼层
	int m_nSecureFoor;//英雄当前楼层

	int m_nlevel;//等级
	int m_nhp;//血量
	int m_natt;//攻击力
	int m_ndef;//防御力
	
	int m_nmoney;//金钱
	int m_nexp;//经验

	
public:
	CCopyTemp(ETYPEBase Type_, int m_nx_, int m_ny_,const char m_cname_[20]="123",int m_nMaxFloor_ = 0, 
			  int m_nSecureFoor_ = 0, int m_nlevel_ = 0, int m_nhp_ = 0, int m_natt_ = 0
		      ,int m_ndef_ = 0,  int m_nmoney_ = 0, int m_nexp_ = 0)
	{
		n_CCopyTempSize = sizeof(CCopyTemp);
		Type = Type_;
		m_nMaxFloor = m_nMaxFloor_;
		m_nSecureFoor = m_nSecureFoor_;

		m_nlevel = m_nlevel_;
		m_nhp = m_nhp_;
		m_natt = m_natt_;
		m_ndef = m_ndef_;
		strcpy(m_cname, m_cname_);
		m_nmoney = m_nmoney_;
		m_nexp = m_nexp_;

		m_nx = m_nx_;
		m_ny = m_ny_;

	}
	ETYPEBase GetType()
	{
		return Type;
	}
	int GetX()
	{
		return m_nx;
	}
	int GetY()
	{
		return m_ny;
	}
	char* GetName()
	{
		return m_cname;
	}
	int GetMaxFloor()
	{
		return m_nMaxFloor;
	}
	int GetSecurFloor()
	{
		return m_nSecureFoor;
	}
	int GetLevel()
	{
		return m_nlevel;
	}
	int GetHp()
	{
		return m_nhp;
	}
	int GetAtt()
	{
		return m_natt;
	}
	int GetDef()
	{
		return m_ndef;
	}
	int GetMoney()
	{
		return m_nmoney;
	}
	int GetExp()
	{
		return m_nexp;
	}
};
class CBase {
private:
	ETYPEBase m_eType; //种类	
	int m_nx;//x坐标
	int m_ny;//y坐标
	CBase* cb;
public:
	CBase(ETYPEBase etype, int nx, int ny)//初始化对象
	{
		m_eType = etype;
		m_nx = nx;
		m_ny = ny;
		n_CBaseSize = sizeof(CBase);
	}
	ETYPEBase GetType() {
		return m_eType;
	}//获取对象种类

	//virtual void Load(FILE* pFile) = 0;
	virtual void Save(FILE* pFile) = 0;
	virtual void Print() = 0;//打印函数
	int GetX() { return m_nx; }//获取x坐标
	int GetY() { return m_ny; }//获取y坐标

	int GetPx() { return 4 * m_ny + 4; }
	int GetPy() { return 2 * m_nx + 4; }

	int GetToY(int nY) { return m_ny + nY; }
	int GetToX(int nX) { return m_nx + nX; }

	void SetY1(int ny) { m_ny = ny; }
	void SetX1(int nx) { m_nx = nx; }
	virtual void Die()//死亡后清除或退出
	{
		map[m_nx][m_ny] = 0;//死亡变路
	}
	virtual ~CBase() {}
protected:
	void SetY(int ny) { m_ny += ny; }
	void SetX(int nx) { m_nx += nx; }
};
int* FileRead(int n_Floor, int buf[][Column]);
void FileWriteB(int n_Floor, CBase* Data, int n_stata);//二进制文件写，它写的是class数据结构
void Side(int x, int y)
{
	COORD position;
	position.Y = x;
	position.X = y;
	SetConsoleCursorPosition(screen, position);
}
class CStairs :public CBase
{
public:
	CStairs(ETYPEBase TYPE, int nX, int nY) :CBase(TYPE, nX, nY)
	{
		n_CStairsSize = sizeof(CStairs);
	}
	virtual void Save(FILE* pFile)
	{
		CCopyTemp Temp(GetType(),GetX(),GetY());
		fwrite(&Temp, sizeof(Temp), 1, pFile);
	}
	virtual void Print()
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		if (GetType() == ESTAIR_UP)
			printf("上");
		else printf("下");
		
	}
};
class CBag
{
private:
	int m_hpNum;//血瓶数量
	int m_attNum;//加攻击力的宝石的数量
	int m_defNum;//加防御力的宝石的数量
	int m_YellowKeyNum;//黄钥匙数量
	int m_RedKeyNum;//红钥匙数量
	int m_BlueKeyNum;//蓝钥匙数量
public:
	// 改变血瓶数目
	void setHpNum(int Num)
	{
		m_hpNum += Num;
	}
	// 改变攻击宝石数目//红宝石
	void setAttNum(int Num)
	{
		m_attNum += Num;
	}
	//改变防御宝石数目 //黄宝石
	void setDefNum(int Num)
	{
		m_defNum += Num;
	}
	//改变黄钥匙数量
	void setYellowKeyNum(int Num)
	{
		m_YellowKeyNum += Num;
	}
	//改变蓝钥匙数量
	void setBlueKeyNum(int Num)
	{
		m_BlueKeyNum += Num;
	}
	//改变红钥匙数量
	void setRedKeyNum(int Num)
	{
		m_RedKeyNum += Num;
	}
	//获取血瓶数目
	int getHpNum()
	{
		return m_hpNum;
	}
	// 获取攻击宝石数目
	int getAttNum()
	{
		return m_attNum;
	}
	//获取防御宝石数目
	int getDefNum()
	{
		return m_defNum;
	}
	//获取黄钥匙数量
	int getYellowKeyNum()
	{
		return m_YellowKeyNum;
	}
	//获取蓝钥匙数量
	int getBlueKeyNum()
	{
		return m_BlueKeyNum;
	}
	//获取红钥匙数量
	int getRedKeyNum()
	{
		return m_RedKeyNum;
	}
};
class CWall :public CBase
{

public:
	CWall(int nX, int nY) :CBase(ETYPE_WALL, nX, nY) 
	{
		n_CWallSize = sizeof(CWall);
	}
	virtual void Save(FILE* pFile)
	{
		
		CCopyTemp Temp(GetType(), GetX(), GetY());
		fwrite(&Temp, sizeof(Temp), 1, pFile);
	}
	virtual void Print()
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		SetConsoleTextAttribute(screen, FOREGROUND_BLUE | FOREGROUND_GREEN );
		printf("■");
		SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	}
};

class CMan :public CBase //人物基类
{
protected:
	int m_nlevel;//等级
	int m_nhp;//血量
	int m_natt;//攻击力
	int m_ndef;//防御力
	char m_cname[20];//姓名
	int m_nmoney;//金钱
	int m_nexp;//经验
	//道具类的指针数组（背包）
	//背包长度
public:
	CMan(ETYPEBase eType, const char* pszNasme, int nHp
		, int nlevel, int nMon, int nExp, int nAttr, int nDef, int nX, int nY) : CBase(eType, nX, nY)
	{
		m_nlevel = nlevel;
		m_nhp = nHp;
		m_natt = nAttr;
		m_ndef = nDef;
		strcpy(m_cname, pszNasme);
		m_nmoney = nMon;
		m_nexp = nExp;
	}

	int GetHp() { return m_nhp; }//获取血量
	virtual void Move() {}//传移动枚举类型
	virtual void SetGoods() {}//获取道具存入背包
	virtual void UseGoods() {}//使用道具
	virtual int Attack() = 0;//攻击伤害值
	virtual int Attacked() = 0; //防御值

	char* GetName()
	{
		return m_cname;
	}
	int GetLivel()
	{
		return m_nlevel;
	}
	int GetAtt()
	{
		return m_natt;
	}
	int GetDef()
	{
		return m_ndef;
	}
	int GetExp()
	{
		return m_nexp;
	}
	void SetAtt(int nAtt) { m_natt += nAtt; }//加攻击
	void SetDef(int nDef) { m_ndef += nDef; }//加防御
};

class CHero :public CMan
{
private:
	CBag m_Bag;
	int m_nMaxFloor;//最大楼层
	int m_nSecureFoor;//英雄当前楼层
public:
	CHero(ETYPEBase eType, const char* pszNasme, int nHp
		, int nlevel, int nMon, int nExp, int nAttr, int nDef, int nX, int nY) :CMan(eType, pszNasme, nHp
			, nlevel, nMon, nExp, nAttr, nDef, nX, nY)
	{
		m_nMaxFloor = 1;
		m_nSecureFoor = 1;
		n_CHeroSize = sizeof(CHero);
	}
	int GetMaxFloor()
	{
		return m_nMaxFloor;
	}
	int GetSecureFoor()
	{
		return m_nSecureFoor;
	}
	int SetSecureFoor(int val)
	{
		m_nSecureFoor += val;
		if (m_nMaxFloor < m_nSecureFoor)//设置最大楼层数
		{
			m_nMaxFloor = m_nSecureFoor;
		}
		return m_nSecureFoor;
	}
	virtual void Save(FILE* pFile) override//TODO这里有问题
	{
		/*CCopyTemp Temp(GetType(), GetX(), GetY(), nullptr);
		fwrite(&Temp, sizeof(Temp), 1, pFile);*/
	}
	virtual void Print() override
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		printf("▲  ");
	}
	void SetHp(int nHp) { m_nhp += nHp; }//加血
	virtual int Attack()//攻击伤害值
	{
		return m_natt;
	}
	virtual int Attacked()//防御值
	{
		return m_ndef;
	}
	void Move(EMOVE Dir);
	//使用血瓶
	bool UseHp()
	{
		if (m_Bag.getHpNum()!=0)
		{
			SetHp(100);
			m_Bag.setHpNum(-1);
			Side(2, 4);
			printf("CUE:嘿哈，回血成功，快去玩耍吧！");
			Sleep(2000);
			Side(2, 4);
			printf("                                   ");
			ShowHeroMsg();
			ShowHeroMsg_();
			return true;
		}
		else
		{
			Side(2, 4);
			printf("CUE:血瓶不够哦，快去闯关积攒吧！");
			Sleep(2000);
			Side(2, 4);
			printf("                                   ");
		}
		return false;
	}
	//使用宝石
	bool UseDef(ETYPEBase Type)
	{
		if (m_Bag.getDefNum()!=0 && Type == EGOODS_DEF)
		{
			SetDef(10);
			m_Bag.setDefNum(-1);
			Side(2, 4);
			printf("CUE:嘿哈，我已强化防御，来打我啊！");
			Sleep(2000);
			Side(2, 4);
			printf("                                   ");
			ShowHeroMsg_();
			ShowHeroMsg();
			return true;
		}
		else if (m_Bag.getAttNum()!=0 && Type == EGOODS_ATT)
		{
			SetAtt(10);
			m_Bag.setAttNum(-1);
			Side(2, 4);
			printf("CUE:嘿哈，我已强化攻击，与我一战？！");
			Sleep(2000);
			Side(2, 4);
			printf("                                   ");
			ShowHeroMsg();
			ShowHeroMsg_();
			return true;
		}
		else
		{
			Side(2, 4);
			printf("CUE:宝石不够哦，快去闯关积攒吧！");
			Sleep(2000);
			Side(2, 4);
			printf("                                  ");
		}
		return false;
	}
	bool UseKey(ETYPEBase Type)//使用钥匙
	{
		if (Type == EDOOR_BULEDOOR && m_Bag.getBlueKeyNum() != 0)//蓝钥匙
		{
			m_Bag.setBlueKeyNum(-1);//蓝钥匙数量减1
			return true;
		}
		else if (Type == EDOOR_YELLOWDOOR && m_Bag.getYellowKeyNum() != 0)//黄钥匙
		{
			m_Bag.setYellowKeyNum(-1);//黄钥匙数量减一
			return true;
		}
		else if (Type == EDOOR_REDDOOR && m_Bag.getRedKeyNum() != 0)//红钥匙
		{
			m_Bag.setRedKeyNum(-1);//红钥匙
			return true;
		}
		return false;
	}
	//获取物品
	void ObtainGoods(ETYPEBase Type)
	{
		switch (Type)
		{
		case EGOODS_ATT://红宝石
		{
			m_Bag.setAttNum(1);

		}
		break;
		case EGOODS_DEF:	 //黄宝石
		{
			m_Bag.setDefNum(1);
		}
		break;
		case EGOODS_FLY://飞行器
		{

		}
		break;
		case EGOODS_YELLOWKEY://黄钥匙
		{
			m_Bag.setYellowKeyNum(1);
		}
		break;
		case EGOODS_REDKEY://红钥匙
		{
			m_Bag.setRedKeyNum(1);
		}
		break;
		case EGOODS_BULEKEY://蓝钥匙
		{
			m_Bag.setBlueKeyNum(1);
		}
		break;
		case EGOODS_LOOK://怪物图鉴
		{

		}
		break;
		case EGOODS_HP://血瓶
		{
			m_Bag.setHpNum(1);
		}
		break;
		}
	}
	void ShowHeroMsg_()
	{
		Side(4, 54);
		printf(" *******英雄信息******");
		Side(5, 54);
		printf(" -——————————");
		Side(6, 54);
		printf(" |   等级   |    %d   |",GetLivel());
		Side(7, 54);
		printf(" -——————————");
		Side(8, 54);
		printf(" |   血量   |  %d   |", GetHp());
		Side(9, 54);
		printf(" -——————————");
		Side(10, 54);
		printf(" |  防御力  |    %d   |", Attacked());
		Side(11, 54);
		printf(" -——————————");
		Side(12, 54);
		printf(" |  攻击力  |    %d   |",Attack());
		Side(13, 54);
		printf(" -——————————");
		Side(14, 54);
		printf(" | 当前楼层 |  %d     |", GetSecureFoor());
		Side(15, 54);
		printf(" -——————————");
	}
	void ShowHeroMsg()
	{
		Side(4, 78);
		printf(" ********背包信息******");
		Side(5, 78);
		printf(" -——————————");
		Side(6, 78);
		printf(" | 物品种类 | 数  量 |");
		Side(7, 78);
		printf(" -——————————");
		Side(8, 78);
		printf(" |  蓝钥匙  |    %d   |", m_Bag.getBlueKeyNum());
		Side(9, 78);
		printf(" -——————————");
		Side(10, 78);
		printf(" |  红钥匙  |    %d   |", m_Bag.getRedKeyNum());
		Side(11, 78);
		printf(" -——————————");
		Side(12, 78);
		printf(" |  黄钥匙  |    %d   |", m_Bag.getYellowKeyNum());
		Side(13, 78);
		printf(" -——————————");
		Side(14, 78);
		printf(" |  血  瓶  |    %d   |", m_Bag.getHpNum());
		Side(15, 78);
		printf(" -——————————");
		Side(16, 78);
		printf(" |  红宝石  |    %d   |", m_Bag.getAttNum());
		Side(17, 78);
		printf(" -——————————");
		Side(18, 78);
		printf(" |  黄宝石  |    %d   |", m_Bag.getDefNum());
		Side(19, 78);
		printf(" -——————————");
	}
	virtual void UseGoods()//使用道具
	{
		// 查询背包是否有对应的物品可以使用
		//Side(54, 4);
		Side(8, 102);
		int n_x = 8;
		printf("←用它请按y");
		do {
			if (_kbhit())
			{
				switch (_getch())
				{
				case 'W':
				case 'w':
				{
					if (n_x != 8)
					{
						Side(n_x, 102);
						printf("                  ");
						n_x -= 2;
					}

				}
				break;
				case 'S':
				case 's':
				{
					if (n_x != 18)
					{
						Side(n_x, 102);
						printf("                    ");
						n_x += 2;
					}
				}
					break;
				case 'Y':
				case 'y':
				{
					switch (n_x)
					{
					case 8://蓝钥匙
					{
						
					}
					break;
					case 10://红钥匙
					{

					}
					break;
					case 12://黄钥匙
					{

					}
					break;
					case 14://血瓶
					{
						UseHp();
					}
					break;
					case 16://红宝石
					{
						UseDef(EGOODS_ATT);
					}
					break;
					case 18://黄宝石
					{
						UseDef(EGOODS_DEF);
					}
					break;
					}
				}
					break;
				case 'Q'://退出
				case 'q':
				{
					Side(n_x, 102);
					printf("                    ");
					return;
				}
				}
				Side(n_x, 102);
				printf("←用它请按y");
			}
		} while (1);

	}
};

class CBaseMgr//管理器
{
private:
	CBaseMgr() {  };
	std::vector<CBase*> m_pArr;
	int m_pArrLen;
public:
	static CBaseMgr* GetIns()
	{
		static CBaseMgr ins;
		return &ins;
	}
	void AddBase(CBase* poBase)
	{
		m_pArr.push_back(poBase);
	}
	CBase* FindBase(int nX, int nY)//根据坐标查找
	{
		// 遍历数组 查询是否存在对应的下标
		auto begin = m_pArr.begin();
		auto end = m_pArr.end();
		for (; begin != end; ++begin)
		{
			if ((*begin)->GetX() == nX && (*begin)->GetY() == nY)
			{
				return *begin;
			}
		}
		return nullptr;
	}
	void Move_(EMOVE Dir)
	{
		auto begin = m_pArr.begin();
		auto end = m_pArr.end();
		for (; begin != end; ++begin)
		{
			if ((*begin)->GetType() == ETYPE_HERO)
			{
				CHero* Hero = dynamic_cast<CHero*>(*begin);
				Hero->Move(Dir);
				Hero->ShowHeroMsg();
				Hero->ShowHeroMsg_();
				return;
			}
		}
	}
	CHero* FindHero()
	{
		auto begin = m_pArr.begin();
		auto end = m_pArr.end();
		for (; begin != end; ++begin)
		{
			if ((*begin)->GetType() == ETYPE_HERO)
			{
				CHero* Hero = dynamic_cast<CHero*>(*begin);
				return Hero;
			}
		}
	}
	CStairs* FindStirs(ETYPEBase Type)
	{
		auto begin = m_pArr.begin();
		auto end = m_pArr.end();
		for (; begin != end; ++begin)
		{
			if ((*begin)->GetType() == ESTAIR_UP && Type == ESTAIR_UP)
			{
				CStairs* Star = dynamic_cast<CStairs*>(*begin);
				return Star;
			}
			else if ((*begin)->GetType() == ESTAIR_DOWN && Type == ESTAIR_DOWN)
			{
				CStairs* Star = dynamic_cast<CStairs*>(*begin);
				return Star;
			}
		}
	}
	void ChangeFloor(CHero* Hero, ETYPEBase Type);//上下楼
	
	void InitNewGame()//初次进入游戏初始化地图
	{
		FileRead(1, map);
		InitObj(ESTAIR_UP);
	}

	bool Delete(CBase* poBase)
	{
		auto begin = m_pArr.begin();
		auto end = m_pArr.end();
		for (; begin != end; ++begin)
		{
			if (*begin == poBase)
			{
				//map[(*begin)->GetX()][(*begin)->GetY()] = 0;
				delete* begin;
				m_pArr.erase(begin);
				return true;
			}
		}
		return false;
	}
	void SaveByMgr(CBase* poBase, FILE* pFile)
	{
		auto begin = m_pArr.begin();
		auto end = m_pArr.end();
		for (; begin != end; ++begin)
		{
			if (*begin==poBase)
			{
				Side(0, 0);
				printf("%d %d    %d %d    ", poBase->GetX(), poBase->GetY(),(*begin)->GetX(), (*begin)->GetY());
				
				(*begin)->Save(pFile);
			}
		}
	}
	void PrintAll()
	{
		auto begin = m_pArr.begin();
		auto end = m_pArr.end();
		for (; begin != end; ++begin)
		{
			(*begin)->Print();
		}
	}
};
class CMonster :public CMan
{
private:
	CMonster* m;
public:
	CMonster(ETYPEBase eType, const char* pszNasme, int nHp
		, int nlevel, int nMon, int nExp, int nAttr, int nDef, int nX, int nY) :CMan(eType, pszNasme, nHp
			, nlevel, nMon, nExp, nAttr, nDef, nX, nY) 
	{
		n_CMonsterSize = sizeof(CMonster);
	}
	virtual void Save(FILE* pFile) override
	{	
		CCopyTemp Temp(GetType(), GetX(), GetY(), GetName(),0,0,GetLivel(),GetHp(),GetAtt(),GetDef(),0,GetExp());
		fwrite(&Temp, sizeof(Temp), 1, pFile); 
	}
	virtual void Print()//打印自身图标
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		printf("M  ");	
	}
	void SetHp(int nHp) { m_nhp += nHp; }//加血
	void Lost()//死亡后掉落道具
	{}
	virtual int Attack()//攻击伤害值
	{
		return m_natt;
	}
	virtual int Attacked()//防御值
	{
		return m_ndef;
	}
};
class CBaseMgrAttrck//战斗管理器
{
private:
	CBaseMgrAttrck() {  };
public:
	static CBaseMgrAttrck* GetIns()
	{
		static CBaseMgrAttrck ins;
		return &ins;
	}
	void PlayAttrck(CHero* h, CMonster* m)//传英雄和怪物
	{
		while (1)
		{
			Side(20, 54);
			printf(" **************战斗信息**************");
			Side(21, 54);
			printf(" -—————————————————");
			Side(22, 90);
			printf("|");
			Side(22, 54);
			printf(" |%s血量    %d   %s血量   %d  ", h->GetName(),h->GetHp(),m->GetName(),m->GetHp());
			Side(23, 54);
			printf(" -—————————————————");
			Side(24, 90);
			printf("|");
			Side(24, 54);
			printf(" |%s攻击力    %d   %s攻击力  %d  ",h->GetName(), h->Attack(),m->GetName(),m->Attack());
			Side(25, 54);
			printf(" -—————————————————");
			Side(26, 90);
			printf("|");
			Side(26, 54);
			printf(" |%s防御力    %d   %s防御力  %d  ",h->GetName(), h->Attacked(),m->GetName(),m->Attacked());
			Side(27, 54);
			printf(" -—————————————————");
			if (_kbhit())
			{
				switch (_getch())
				{
				case 'Q':
				case 'q':
					return;
				}
			}
			Sleep(800);
			h->SetHp(-(m->Attack() + m->Attacked()));
			m->SetHp(-(h->Attack() + h->Attacked()));
			if (h->GetHp() <= 0)
			{
				std::cout << "主角死亡游戏结束" << std::endl;
				map[h->GetX()][h->GetY()] = 0;
				exit(0);
			}	

			else if (m->GetHp() <= 0)
			{
				CBaseMgr::GetIns()->Delete(m);
				break;
			}
		}	
	}
};

//物品基类
class CGoods :public CBase
{
private:
	int m_nNum; //数量
public:
	CGoods(ETYPEBase typ, int nX, int nY, int nNum = 0) :CBase(typ, nX, nY) {}

	int GetNum()
	{
		return m_nNum;
	}
	void SetNum(int nNum)
	{
		m_nNum += nNum;
	}
};
//血瓶实体
class CGoodsHp :public CGoods
{
public:
	//int nNum,int nX, int nY  数量   x，y坐标
	CGoodsHp(ETYPEBase typ, int nX, int nY, int nNum) :CGoods(typ, nX, nY, nNum)
	{
		n_CGoodsHpSize = sizeof(CGoodsHp);
	}
	virtual void Save(FILE* pFile) override
	{
		CCopyTemp Temp(GetType(), GetX(), GetY());
		fwrite(&Temp, sizeof(Temp), 1, pFile);
	}
	virtual void Print()
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		SetConsoleTextAttribute(screen, FOREGROUND_RED);
		printf("i   ");
		SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	}
};
//宝石实体
class CGoodsGem :public CGoods
{
public:
	//int nNum,int nX, int nY  数量   x，y坐标
	CGoodsGem(ETYPEBase typ, int nX, int nY, int nNum) :CGoods(typ, nX, nY, nNum)
	{
		n_CGoodsGemSize = sizeof(CGoodsGem);
	}
	virtual void Save(FILE* pFile) override
	{
		CCopyTemp Temp(GetType(), GetX(), GetY());
		fwrite(&Temp, sizeof(Temp), 1, pFile);
	}
	virtual void Print()
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		if (GetType() == EGOODS_ATT)
		{
			SetConsoleTextAttribute(screen, FOREGROUND_RED);
			printf("*   ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
		else
		{
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN);
			printf("*  ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
	}
};
class CDoor :public CBase
{
	//类型
public:
	CDoor(ETYPEBase e, int nX, int nY) :CBase(e, nX, nY) {}
	virtual void Save(FILE* pFile) override
	{
		CCopyTemp Temp(GetType(), GetX(), GetY());
		fwrite(&Temp, sizeof(Temp), 1, pFile);
	}
	virtual void Print() override
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		if (GetType() == EDOOR_REDDOOR)
		{
			SetConsoleTextAttribute(screen, FOREGROUND_RED);
			printf("円  ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
		else if (GetType() == EDOOR_BULEDOOR)
		{
			SetConsoleTextAttribute(screen, FOREGROUND_BLUE);
			printf("円  ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
		else if (GetType() == EDOOR_YELLOWDOOR)
		{
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN);
			printf("円  ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
		n_CDoorSize = sizeof(CDoor);
	}
};

void FileReadB(FILE* pFile,int n_Floor);//二进制文件读,他读取的是class数据结构
//钥匙实体
class CGoodsKey :public CGoods
{
public:
	//int nNum,int nX, int nY  数量   x，y坐标
	CGoodsKey(ETYPEBase typ, int nX, int nY, int nNum) :CGoods(typ, nX, nY, nNum)
	{
		n_CGoodsKeySize = sizeof(CGoodsKey);
	}
	virtual void Save(FILE* pFile) override
	{
		CCopyTemp Temp(GetType(), GetX(), GetY());
		fwrite(&Temp, sizeof(Temp), 1, pFile);
	}
	virtual void Print()
	{
		COORD position;
		position.X = GetPx();
		position.Y = GetPy();
		SetConsoleCursorPosition(screen, position);
		if (GetType() == EGOODS_YELLOWKEY)//黄钥匙
		{
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN);
			printf("钥  ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
		else if (GetType() == EGOODS_BULEKEY)//蓝钥匙
		{
			SetConsoleTextAttribute(screen, FOREGROUND_BLUE);
			printf("钥  ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
		else//红钥匙
		{
			SetConsoleTextAttribute(screen, FOREGROUND_RED);
			printf("钥  ");
			SetConsoleTextAttribute(screen, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
		}
	}
};
void CHero::Move(EMOVE Dir)//传移动枚举类型
{
	CBase* pHero = CBaseMgr::GetIns()->FindBase(GetX(), GetY());
	CHero* Hreo = dynamic_cast<CHero*>(pHero);
	switch (Dir)
	{
	case EMOVE_UP://人物是15
	{
		CBase* pBase = CBaseMgr::GetIns()->FindBase(GetToX(-1), GetToY(0));
		if (pBase == NULL)//路
		{
			SetX(-1);
			break;
		}
		else if (pBase->GetType() >= EGOODS_ATT && pBase->GetType() <= EGOODS_BULEKEY)//红宝石->蓝钥匙的区间
		{
			Hreo->ObtainGoods(pBase->GetType());
			CBaseMgr::GetIns()->Delete(pBase);//在vector中清除
			SetX(-1);
			break;
		}
		else if (pBase->GetType() >= ESTAIR_DOWN && pBase->GetType() <= ESTAIR_UP)//上楼->下楼的区间
		{
			CBaseMgr::GetIns()->ChangeFloor(Hreo, pBase->GetType());
			CBaseMgr::GetIns()->FindHero()->SetX1(CBaseMgr::GetIns()->FindStirs(ESTAIR_DOWN)->GetX() - 1);
			CBaseMgr::GetIns()->FindHero()->SetY1(CBaseMgr::GetIns()->FindStirs(ESTAIR_DOWN)->GetY());
			break;
		}
		else if (pBase->GetType() >= EDOOR_REDDOOR && pBase->GetType() <= EDOOR_YELLOWDOOR)//红门->黄门的区间
		{
			if (Hreo->UseKey(pBase->GetType()))
			{
				CBaseMgr::GetIns()->Delete(pBase);//在vector中清除
				SetX(-1);
			}
			break;
		}
		switch (pBase->GetType())
		{
		case ETYPE_MONSTER:
		{
			CMonster* m1 = dynamic_cast<CMonster*>(pBase);
			CBaseMgrAttrck::GetIns()->PlayAttrck(Hreo, m1);//前方是怪物
			SetX(-1);
		}
		break;
		case ETYPE_WALL://墙
			break;
		default:printf("其他");
			break;
		}
		break;
	}
	case EMOVE_DOWN:
	{
		CBase* pBase = CBaseMgr::GetIns()->FindBase(GetToX(1), GetToY(0));
		if (pBase == NULL)
		{
			SetX(1);
			break;
		}
		else if (pBase->GetType() >= EGOODS_ATT && pBase->GetType() <= EGOODS_BULEKEY)//红宝石->蓝钥匙的区间
		{
			Hreo->ObtainGoods(pBase->GetType());
			if(CBaseMgr::GetIns()->Delete(pBase))//在vector中清除
			SetX(1);
			break;
		}
		else if (pBase->GetType() >= ESTAIR_DOWN && pBase->GetType() <= ESTAIR_UP)//上楼->下楼的区间
		{
			CBaseMgr::GetIns()->ChangeFloor(Hreo, pBase->GetType());
			CBaseMgr::GetIns()->FindHero()->SetX1(CBaseMgr::GetIns()->FindStirs(ESTAIR_UP)->GetX() + 1);
			CBaseMgr::GetIns()->FindHero()->SetY1(CBaseMgr::GetIns()->FindStirs(ESTAIR_UP)->GetY()); 
			break;
		}
		else if (pBase->GetType() >= EDOOR_REDDOOR && pBase->GetType() <= EDOOR_YELLOWDOOR)//红门->黄门的区间
		{
			if (Hreo->UseKey(pBase->GetType()))
			{
				CBaseMgr::GetIns()->Delete(pBase);//在vector中清除
				SetX(1);
			}
			break;
		}
		switch (pBase->GetType())
		{
		case ETYPE_MONSTER:
		{
			CMonster* m1 = dynamic_cast<CMonster*>(pBase);
			CBaseMgrAttrck::GetIns()->PlayAttrck(Hreo, m1);//前方是怪物
			SetX(1);
		}
		break;
		case ETYPE_WALL://墙
			break;
		default:printf("其他");
			break;
		}
		break;
	}
	case EMOVE_LEFT:
	{
		CBase* pBase = CBaseMgr::GetIns()->FindBase(GetToX(0), GetToY(-1));

		if (pBase == NULL)
		{
			SetY(-1);
			break;
		}
		else if (pBase->GetType() >= EGOODS_ATT && pBase->GetType() <= EGOODS_BULEKEY)//红宝石->蓝钥匙的区间
		{
			Hreo->ObtainGoods(pBase->GetType());
			CBaseMgr::GetIns()->Delete(pBase);//在vector中清除
			SetY(-1);
			break;
		}
		else if (pBase->GetType() >= ESTAIR_DOWN && pBase->GetType() <= ESTAIR_UP)//上楼->下楼的区间
		{
			CBaseMgr::GetIns()->ChangeFloor(Hreo, pBase->GetType());
			if (pBase->GetType() == ESTAIR_DOWN)
			{
				CBaseMgr::GetIns()->FindHero()->SetX1(CBaseMgr::GetIns()->FindStirs(ESTAIR_UP)->GetX() + 1);
				CBaseMgr::GetIns()->FindHero()->SetY1(CBaseMgr::GetIns()->FindStirs(ESTAIR_UP)->GetY());
			}
			else
			{
				CBaseMgr::GetIns()->FindHero()->SetX1(CBaseMgr::GetIns()->FindStirs(ESTAIR_DOWN)->GetX() - 1);
				CBaseMgr::GetIns()->FindHero()->SetY1(CBaseMgr::GetIns()->FindStirs(ESTAIR_DOWN)->GetY());
			}
			break;
		}
		else if (pBase->GetType() >= EDOOR_REDDOOR && pBase->GetType() <= EDOOR_YELLOWDOOR)//红门->黄门的区间
		{
			if (Hreo->UseKey(pBase->GetType()))
			{
				CBaseMgr::GetIns()->Delete(pBase);//在vector中清除
				SetY(-1);
			}
			break;
		}
		switch (pBase->GetType())
		{
		case ETYPE_MONSTER:
		{
			CMonster* m1 = dynamic_cast<CMonster*>(pBase);
			CBaseMgrAttrck::GetIns()->PlayAttrck(Hreo, m1);//前方是怪物
			SetY(-1);
		}
		break;
		case ETYPE_WALL://墙
			break;
		default:printf("其他");
			break;
		}
		break;
	}
	case EMOVE_RIGHT:
	{
		CBase* pBase = CBaseMgr::GetIns()->FindBase(GetToX(0), GetToY(1));
		if (pBase == NULL)
		{
			SetY(1);
			break;
		}
		else if (pBase->GetType() >= EGOODS_ATT && pBase->GetType() <= EGOODS_BULEKEY)//红宝石->蓝钥匙的区间
		{
			Hreo->ObtainGoods(pBase->GetType());
			CBaseMgr::GetIns()->Delete(pBase);//在vector中清除
			SetY(1);
			break;
		}
		else if (pBase->GetType() >= ESTAIR_DOWN && pBase->GetType() <= ESTAIR_UP)//上楼->下楼的区间
		{
			CBaseMgr::GetIns()->ChangeFloor(Hreo, pBase->GetType());
			if (pBase->GetType() == ESTAIR_DOWN)
			{
				CBaseMgr::GetIns()->FindHero()->SetX1(CBaseMgr::GetIns()->FindStirs(ESTAIR_UP)->GetX() + 1);
				CBaseMgr::GetIns()->FindHero()->SetY1(CBaseMgr::GetIns()->FindStirs(ESTAIR_UP)->GetY());
			}
			else
			{
				CBaseMgr::GetIns()->FindHero()->SetX1(CBaseMgr::GetIns()->FindStirs(ESTAIR_DOWN)->GetX() - 1);
				CBaseMgr::GetIns()->FindHero()->SetY1(CBaseMgr::GetIns()->FindStirs(ESTAIR_DOWN)->GetY());
			}
			break;
		}
		else if (pBase->GetType() >= EDOOR_REDDOOR && pBase->GetType() <= EDOOR_YELLOWDOOR)//红门->黄门的区间
		{
			if (Hreo->UseKey(pBase->GetType()))
			{
				CBaseMgr::GetIns()->Delete(pBase);//在vector中清除
				SetY(1);
			}
			break;
		}
		switch (pBase->GetType())
		{
		case ETYPE_MONSTER:
		{
			CMonster* m1 = dynamic_cast<CMonster*>(pBase);
			CBaseMgrAttrck::GetIns()->PlayAttrck(Hreo, m1);//前方是怪物
			SetY(1);
		}
		break;
		case ETYPE_WALL://墙
			break;
		default:printf("其他");
			break;
		}
		break;
	}
	default:
		break;
	}
	system("cls");
	CBaseMgr::GetIns()->PrintAll();
}
	char buf1[10];//itoa
	char buf3[5] = ".txt";//itoa
	void itoa1(int a, char p[])
	{
		int i = 0;
		char c;
		do
		{
			p[i++] = a % 10 + '0';
			a /= 10;
		} while (a != 0);
		p[i] = '\0';
		int s = i;
		for (int j = 0; j < s / 2; j++)
		{
			c = p[j];
			p[j] = p[--i];
			p[i] = c;
		}
	}

	int* FileRead(int n_Floor, int buf[][Column])
	{
		itoa1(n_Floor, buf1);
		strcat(buf1, buf3);
		FILE* pFile = fopen(buf1, "r+");
		if (nullptr == pFile)
		{
			printf("文件打开失败\n");
			system("pause");
		}
		int n[1000] = { 0 };
		int m = 0;
		for (int i = 0; fscanf(pFile, "%d", n + i) != EOF; i++);
		for (int i = 0; i < Row; i++)
		{
			for (int j = 0; j < Column; j++)
			{
				buf[i][j] = n[m];
				m++;
			}
		}
		fclose(pFile);
		return *buf;
	}
	void HeroFileWriteB(CHero* Data)//二进制文件写，它写的是class数据结构,存英雄
	{
		FILE* pFile = fopen("HERO", "wb");
		fwrite(Data, sizeof(Data), 1, pFile);
		fclose(pFile);
	}
	CHero* HeroFileReadB()//二进制文件读,他读取的是class数据结构,读英雄
	{
		CHero* Data = new CHero(ETYPE_HERO, "dd", 100, 1, 1, 1, 10, 10, 7, 5);
		FILE* pFile = fopen("HERO", "rb");
		fread(Data, sizeof(Data), 1, pFile);
		fclose(pFile);
		return Data;
	}
	void FileReadB(FILE* pFile)//二进制文件读,他读取的是class数据结构
	{
		char buf[1024] = {0};

		fread(buf, 4, 1, pFile);
		ETYPEBase Type = *(ETYPEBase*)buf;
		switch (Type)
		{
		case ETYPE_WALL:
		{
			fread(buf + 4, n_CCopyTempSize - 4, 1, pFile);
			CCopyTemp T1= *(CCopyTemp*)buf;
			CWall* Wall = new CWall(T1.GetX(), T1.GetY());//墙
			CBaseMgr::GetIns()->AddBase(Wall);
		}
		break;

		case ETYPE_MONSTER:
		{
			fread(buf + 4, n_CCopyTempSize - 4, 1, pFile);
			CCopyTemp T1 = *(CCopyTemp*)buf;
			CMonster* Monster1 = new CMonster(T1.GetType(), T1.GetName(), 1, 1, 1, 1, 1, 1,T1.GetX(), T1.GetY());//怪物
			CBaseMgr::GetIns()->AddBase(Monster1);
		}
		break;

		case EGOODS_FLY:
			break;

		case EGOODS_ATT:
		case EGOODS_DEF:
		{
			fread(buf + 4, n_CCopyTempSize - 4, 1, pFile);
			CCopyTemp T1 = *(CCopyTemp*)buf;
			CGoodsGem* Ruby = new CGoodsGem(T1.GetType(), T1.GetX(), T1.GetY(), 1);//红宝石
			CBaseMgr::GetIns()->AddBase(Ruby);
		}
		break;

		case EGOODS_HP:
		{
			fread(buf + 4, n_CCopyTempSize - 4, 1, pFile);
			CCopyTemp T1 = *(CCopyTemp*)buf;
			CGoodsHp* BloodVial = new CGoodsHp(T1.GetType(), T1.GetX(), T1.GetY(), 1);//血瓶
			CBaseMgr::GetIns()->AddBase(BloodVial);
		}
		break;

		case EGOODS_LOOK:
			break;

		case EGOODS_YELLOWKEY:
		case EGOODS_REDKEY:
		case EGOODS_BULEKEY:
		{
			fread(buf + 4, n_CCopyTempSize - 4, 1, pFile);
			CCopyTemp T1 = *(CCopyTemp*)buf;
			CGoodsKey* Key = new CGoodsKey(T1.GetType(), T1.GetX(), T1.GetY(), 1);//黄钥匙
			CBaseMgr::GetIns()->AddBase(Key);
		}
		break;

		case ESTAIR_UP:
		case ESTAIR_DOWN:
		{
			fread(buf + 4, n_CCopyTempSize - 4, 1, pFile);
			CCopyTemp T1 = *(CCopyTemp*)buf;
			CStairs* Go = new CStairs(T1.GetType(), T1.GetX(), T1.GetY());//下楼
			CBaseMgr::GetIns()->AddBase(Go);
		}
		break;
		case EDOOR_REDDOOR:
		case EDOOR_BULEDOOR:
		case EDOOR_YELLOWDOOR:
		{
			fread(buf + 4, n_CCopyTempSize - 4, 1, pFile);
			CCopyTemp T1 = *(CCopyTemp*)buf;
			CDoor* Door = new CDoor(T1.GetType(), T1.GetX(), T1.GetY());
			CBaseMgr::GetIns()->AddBase(Door);//蓝门
		}
		break;
		}
	}

void InitObj(ETYPEBase Type)//用于设置英雄坐标
{
	for (int i = 0; i < 13; ++i)
	{
		for (int j = 0; j < 13; ++j)
		{
			switch (map[i][j])
			{
			case 1:
			case 2:
			{
				CWall* Wall = new CWall(i, j);//墙
				CBaseMgr::GetIns()->AddBase(Wall);
			}
			break;
			case 3:
			{
				CDoor* RedDoor = new CDoor(EDOOR_REDDOOR, i, j);
				CBaseMgr::GetIns()->AddBase(RedDoor);//红门
			}
			break;
			case 4:
			{
				CDoor* YellowDoor = new CDoor(EDOOR_YELLOWDOOR, i, j);
				CBaseMgr::GetIns()->AddBase(YellowDoor);//黄门
			}
			break;
			case 5:
			{
				CDoor* BlueDoor = new CDoor(EDOOR_BULEDOOR, i, j);
				CBaseMgr::GetIns()->AddBase(BlueDoor);//蓝门
			}
			break;
			case 6:
			{
				CGoodsHp* BloodVial = new CGoodsHp(EGOODS_HP, i, j, 1);//血瓶
				CBaseMgr::GetIns()->AddBase(BloodVial);
			}
			break;
			case 10:
			{
				CStairs* GoUp = new CStairs(ESTAIR_UP, i, j);//上楼
				CBaseMgr::GetIns()->AddBase(GoUp);
			}
			break;
			case 11:
			{
				CStairs* GoDown = new CStairs(ESTAIR_DOWN, i, j);//下楼
				CBaseMgr::GetIns()->AddBase(GoDown);
			}
			break;
			case 12:
			{
				CGoodsKey* YelloKey = new CGoodsKey(EGOODS_YELLOWKEY, i, j, 1);//黄钥匙
				CBaseMgr::GetIns()->AddBase(YelloKey);
			}
			break;
			case 13:
			{
				CGoodsKey* RedKey = new CGoodsKey(EGOODS_REDKEY, i, j, 1);//红钥匙
				CBaseMgr::GetIns()->AddBase(RedKey);
			}
			break;
			case 14:
			{
				CGoodsKey* BlueKey = new CGoodsKey(EGOODS_BULEKEY, i, j, 1);//蓝钥匙
				CBaseMgr::GetIns()->AddBase(BlueKey);
			}
			break;
			case 16:
			{
				CGoodsGem* Ruby = new CGoodsGem(EGOODS_ATT, i, j, 1);//红宝石
				CBaseMgr::GetIns()->AddBase(Ruby);
			}
			break;
			case 17:
			{
				CGoodsGem* Topaz = new CGoodsGem(EGOODS_DEF, i, j, 1);//黄宝石
				CBaseMgr::GetIns()->AddBase(Topaz);
			}
			break;
			case 30:
			{
				CMonster* Monster1 = new CMonster(ETYPE_MONSTER, "青头怪", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster1);
			}
			break;
			case 31:
			{
				CMonster* Monster2 = new CMonster(ETYPE_MONSTER, "红头怪", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster2);
			}
			break;
			case 32:
			{
				CMonster* Monster3 = new CMonster(ETYPE_MONSTER, "骷髅人", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster3);
			}
			break;
			case 33:
			{
				CMonster* Monster4 = new CMonster(ETYPE_MONSTER, "初级法师", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster4);
			}
			break;
			case 34:
			{
				CMonster* Monster5 = new CMonster(ETYPE_MONSTER, "绿头怪", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster5);
			}
			break;
			case 35:
			{
				CMonster* Monster6 = new CMonster(ETYPE_MONSTER, "小蝙蝠", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster6);
			}
			break;
			case 36:
			{
				CMonster* Monster7 = new CMonster(ETYPE_MONSTER, "兽面人", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster7);
			}
			break;
			case 37:
			{
				CMonster* Monster8 = new CMonster(ETYPE_MONSTER, "骷髅士兵", 20, 1, 1, 1, 2, 1, i, j);//怪物
				CBaseMgr::GetIns()->AddBase(Monster8);
			}
			break;
			}
		}
	}
}
void ShowBegin()
{
	Side(4,50);
	printf(" \033[41m\033[37m FBI WARNING \033[0m");
	Side(6, 25);
	printf("Federal L aw provides severe civil and criminal penalties for\n");
	Side(7, 25);
	printf("the unauthorized reproduction, distribution, or exhibition of\n");
	Side(8, 25);
	printf("copyrighted motion pictures (Title 17, United States Code,\n");
	Side(9, 25);
	printf("Sections 501 and 508). The Federal Bureau of Investigation\n");
	Side(10, 25);
	printf("investigates allegations of criminal copyright infringement\n");
	Side(11, 25);
	printf("     (Title 17, United States Code, Section 506).");
	Sleep(5000);
	system("cls");
}
int main()
{
	//ShowBegin();
	CBaseMgr::GetIns()->InitNewGame();
	CHero* Chero = new CHero(ETYPE_HERO, "dd", 1000, 1, 1, 1, 2, 1, 7, 5);
	CBaseMgr::GetIns()->AddBase(Chero);
	CBaseMgr::GetIns()->PrintAll();
	Chero->ShowHeroMsg();
	Chero->ShowHeroMsg_();
	do {
		if (_kbhit())
		{
			switch (_getch())
			{
			case 'A':
			case 'a':
				CBaseMgr::GetIns()->Move_(EMOVE_LEFT);
				break;
			case 'D':
			case 'd':
				CBaseMgr::GetIns()->Move_(EMOVE_RIGHT);
				break;
			case 'W':
			case 'w':
				CBaseMgr::GetIns()->Move_(EMOVE_UP);
				break;
			case 'S':
			case 's':
				CBaseMgr::GetIns()->Move_(EMOVE_DOWN);
				break;
			case 'U':
			case 'u':
				CBaseMgr::GetIns()->FindHero()->UseGoods();
			default:
				break;
			}
		
		}
	} while (1);
	system("pause");
	return 0;
}

void CBaseMgr::ChangeFloor(CHero* Hero, ETYPEBase Type)
{
	int n_stata = 0;//第一次存储标志
	auto begin = m_pArr.begin();
	auto end = m_pArr.end();
	int n_Floor = Hero->GetSecureFoor();//获取当前楼层
	int n_size = 0;
	char buf2[10];//itoa
	int nFloorto = n_Floor;
	n_Floor = n_Floor * 10 + n_Floor;//转换文本名
	itoa1(n_Floor, buf1);
	strcat(buf1, buf3);

	FILE* pFile = fopen(buf1, "wb");//清空当前楼层文本
	fclose(pFile);
	
	FILE* pFile1 = fopen(buf1, "ab");
	int t = 0;
	for (; begin != end; ++begin)
	{
		if ((*begin)->GetType() == ETYPE_HERO)
		{
			++t;
			continue;//不将Hero存入这个文档
		}
		CBaseMgr::GetIns()->SaveByMgr(*begin, pFile1);
	}
	fclose(pFile1);
	begin = m_pArr.begin();
	end = m_pArr.end();
	int temp = 0;
	for (; begin != end; begin++)
	{
		if ((*begin)->GetType() == ETYPE_HERO)
		{
			continue;//不将Hero存入这个文档
		}
		delete* begin;//
		m_pArr.erase(begin);
		begin = m_pArr.begin();//清空除英雄外的所有Vector数据
		end = m_pArr.end();
	}
	if (Type == ESTAIR_UP)
	{
		nFloorto = nFloorto + 1;
		nFloorto = nFloorto * 10 + nFloorto;
		itoa1(nFloorto, buf2);
		strcat(buf2, buf3);
	}
	else if (Type == ESTAIR_DOWN)
	{
		nFloorto = nFloorto - 1;
		nFloorto = nFloorto * 10 + nFloorto;
		itoa1(nFloorto, buf2);
		strcat(buf2, buf3);
	}

	if(Hero->GetMaxFloor() == Hero->GetSecureFoor() && Type == ESTAIR_UP)
	{
		FileRead(Hero->SetSecureFoor(Type), map);//获取新地图
		InitObj(ESTAIR_UP);//初始化对象//TODO
	}
	else 
	{
		FILE* pFile = fopen(buf2, "rb");
		Hero->SetSecureFoor(Type);//设置楼层
		while (!feof(pFile))
		{
			FileReadB(pFile);//TODO这里要读取下一个
		}
		fclose(pFile);
	}
}
